//
//  RCActivityDetailInfoModel.m
//  RocketProject
//
//  Created by chen jiedan on 13-10-4.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCActivityDetailInfoModel.h"
#import "KFObjectExtension.h"

@implementation RCActivityItemInfo

@synthesize title = _title;
@synthesize picUrl = _picUrl;
@synthesize content =_content;


- (void) dealloc
{
    KF_RELEASE_SAFELY(_title);
    KF_RELEASE_SAFELY(_picUrl);
    KF_RELEASE_SAFELY(_content);
    [super dealloc];
}


@end

@implementation RCActivityDetailInfoModel

// 将JSON数据解析为数据模型
+(id) parseDataFromJSON:(NSDictionary*)data
{
    // 输入参数判断
    if ( nil == data )
        return nil;
    NSMutableArray *listItems = [[NSMutableArray alloc] init];
    
    RCActivityDetailInfoModel *retObject = [[[RCActivityDetailInfoModel alloc] init] autorelease];
    NSDictionary *dataDic = [data dictionaryValueForKey:@"data" defaultValue:nil];
   
    
    NSArray *dataItems = [dataDic arrayValueForKey:@"list" defaultValue:nil];
    if (nil == dataItems) {
        dataItems = [dataDic arrayValueForKey:@"items" defaultValue:nil];
    }
    for (NSDictionary *dic in dataItems) {
        RCActivityItemInfo *item = [[RCActivityItemInfo alloc] init];
        item.title = [dic stringValueForKey:@"title" defaultValue:@"" operation:NSStringOperationTypeNone];
        item.content = [dic stringValueForKey:@"content" defaultValue:@"" operation:NSStringOperationTypeNone];
        item.picUrl = [dic stringValueForKey:@"picurl" defaultValue:@"" operation:NSStringOperationTypeNone];
        [listItems addObject:item];
        [item release];
    }
    retObject.listItems = listItems;
    [listItems release];
    return retObject;
}


@end
